﻿' Copyright (C) 2011  Jan-Willem de Bruyn
'
'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.
'
'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.
'
'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Imports WindowsApplication1.Form1
Public Class liberdy

    'dim stuff
    Dim answer As String
    Dim veranderdenaam As String
    Dim bericht As String
    Dim pro As String

    'load form
    Private Sub liberdy_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form1.Hide()

    End Sub
    'send only message
    Private Sub ber()
        ListBox1.Items.Add("liberdy: " & bericht)
    End Sub
    'start only programme
    Private Sub prostart()
        Process.Start(pro)
    End Sub


    'do call programme and send text
    Private Sub both()
        Call prostart()
        Call ber()
    End Sub

    'do stuff when button is pressed
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(namer & ": " & TextBox1.Text)

        Call antwoorden()
        TextBox1.Clear()
        ListBox1.TopIndex = ListBox1.Items.Count - 1

    End Sub

    'press enter to send message
    Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

        If e.KeyCode = Keys.Enter Then Button1.PerformClick()
    End Sub



    'fill in name and go to textbox1
    Private Sub naam_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Enter Then TextBox1.Select()
    End Sub
    'answers
    Public Sub antwoorden()
        'declare input and convert to lowercase
        Dim custommessage As String = TextBox1.Text
        Dim lower As String = LCase(custommessage)

        If lower Like "*explorer*" Then
            pro = "explorer.exe"
            bericht = "what do you search?"
            Call both()

        ElseIf lower Like "*hello*" Then
            bericht = "hello"
            Call ber()

        ElseIf lower Like "*hi*" Then
            bericht = "hi"
            Call ber()

        ElseIf lower Like "*regedit*" Then
            pro = "regedit.exe"
            bericht = "ok"
            Call both()

        ElseIf lower Like "*notepad*" Then
            pro = "notepad.exe"
            Call both()

        ElseIf lower Like "*how are you*" Then
            bericht = "it's great!"
            Call ber()

        ElseIf lower Like "*internet*" Then
            pro = "iexplore.exe"
            bericht = "just have fun!"
            Call both()

        ElseIf lower Like "*music*" Then
            pro = "wmplayer.exe"
            bericht = "that sounds nice!"
            Call both()


        ElseIf lower Like "*what sould I do*?*" Then
            bericht = "just talk to me..."
            Call ber()

        ElseIf lower Like "*lol*" Then
            bericht = "rofl"
            Call ber()

        ElseIf lower Like "*services*" Then
            pro = "services.msc"
            bericht = "know what you do with this!"
            Call both()


        ElseIf lower Like "*crazy*" Then
            bericht = "'crazy'... what do you mean?"
            Call ber()

        ElseIf lower Like "*good morning*" Then
            bericht = "good morning..."
            Call ber()

        ElseIf lower Like vbNullString Then
            bericht = "you must write something before I can answer..."
            Call ber()

        ElseIf lower Like "*shutdown*" Then
            MyBase.Close()

        Else
            Call anders()

        End If

    End Sub
    'elsemethod
    Private Sub anders()
        Dim ramdom As Integer
        ramdom = 1 + CInt(6 * Rnd())
        Select Case ramdom
            Case 1
                ListBox1.Items.Add("liberdy: what do you mean by this?")
            Case 2
                ListBox1.Items.Add("liberdy: I don't know")
            Case 3
                ListBox1.Items.Add("liberdy: I don't know what to do with this")
            Case 4
                ListBox1.Items.Add("liberdy: just talk normal!")
            Case 5
                ListBox1.Items.Add("liberdy: IDK")
            Case 6
                ListBox1.Items.Add("liberdy: please speak normally...")

        End Select
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form1.Show()
    End Sub

    Private Sub close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles close.Click
        MyBase.Close()
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

    End Sub
End Class
